from flask import Flask
from config import Config
from exts import db,loginmanager,bootstrap,bcrypt

app=Flask(__name__)
app.config.from_object(Config)
bootstrap.init_app(app)
db.init_app(app)
bcrypt.init_app(app)
loginmanager.init_app(app)

loginmanager.login_view="loginform"  #对应def loginform 这个函数
loginmanager.login_message="You must login!"
loginmanager.login_message_category='info'

app.app_context().push()

if __name__=="__main__":
    from route import *
    # 创建数据库  第一次运行时
    # db.drop_all()
    # db.create_all()
    # user1=User(username="admin",password=bcrypt.generate_password_hash('12345'),email="admin@gmail.com")
    # user2=User(username="guest",password=bcrypt.generate_password_hash('456'),email="guest@163.com")
    # user3=User(username="yao",password=bcrypt.generate_password_hash('12345'),email="yao@yahoo.com")
    # db.session.add(user1)
    # db.session.add(user2)
    # db.session.add(user3)
    # db.session.commit()
    app.run(debug=True)